package org.itboys.weixin.service;

import java.util.Date;

import javax.annotation.Resource;

import org.itboys.admin.tools.AdminSessionHolder;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.weixin.entity.WeixinSendRecord;
import org.springframework.stereotype.Service;


/**
 * 微信自定义菜单管理
 * @author chenzhiqi
 *
 */
@Service
public class WeixinSendRecordService extends BaseWeixinService<WeixinSendRecord, Long> {

	private static final long serialVersionUID = -7562184153735537374L;
	
	@Resource(name="weixinDS")
	private MongoDataSource sendRecoredDataSource;

	@Override
	protected MongoDataSource getMongoDataSource() {
		return sendRecoredDataSource;
	}

	@Override
	protected Class<WeixinSendRecord> getEntityClass() {
		return WeixinSendRecord.class;
	}
	
	public void save(WeixinSendRecord detail){
		detail.setCreateTime(new Date());
		detail.setCreator(AdminSessionHolder.getAdminUserId());
		super.save(detail);
	}
	
	public void update(WeixinSendRecord detail){
		WeixinSendRecord detail2 = getById(detail.getId());
		detail.setCreateTime(detail2.getCreateTime());
		detail.setCreator(detail2.getCreator());
		detail.setUpdater(AdminSessionHolder.getAdminUserId());
		detail.setUpdateTime(new Date());
		super.update(detail);
	}
	
}
